package com.guigu.handler.impl;

import cn.hutool.core.bean.BeanUtil;
import com.guigu.annotation.SubjectInfoType;
import com.guigu.domain.dto.SubjectInfoDTO;
import com.guigu.domain.entity.SubjectInfo;
import com.guigu.domain.entity.SubjectJudge;
import com.guigu.domain.enums.IsDeletedFlagEnum;
import com.guigu.domain.enums.SubjectInfoEnum;
import com.guigu.handler.SubjectInfoHandler;
import com.guigu.service.ISubjectJudgeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @description: 判断题
 * @author: JZC
 * @create: 2024-06-07 00:21
 **/
@Component("judgeTypeSubjectInfoHandler")
@SubjectInfoType(type = SubjectInfoEnum.JUDGE_TYPE)
@Slf4j
public class JudgeTypeSubjectInfoHandler implements SubjectInfoHandler {

    @Resource
    private ISubjectJudgeService subjectJudgeService;
    @Override
    public void add(SubjectInfoDTO subjectInfoDTO) {
        log.info("判断题添加逻辑代码...");
        SubjectJudge subjectJudge = BeanUtil.toBean(subjectInfoDTO, SubjectJudge.class);
        subjectJudge.setSubjectId(subjectInfoDTO.getId());
        subjectJudge.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        subjectJudgeService.save(subjectJudge);
    }
}
